package org.jivesoftware.smackx.provider;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.packet.XHTMLExtension;
import org.xmlpull.v1.XmlPullParser;

public class XHTMLExtensionProvider
  implements PacketExtensionProvider
{
  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    XHTMLExtension localXHTMLExtension = new XHTMLExtension();
    int i = 0;
    StringBuilder localStringBuilder = new StringBuilder();
    int j = paramXmlPullParser.getDepth();
    int k = paramXmlPullParser.getDepth();
    String str = "";
    while (true)
    {
      do
        while (true)
        {
          while (true)
          {
            int l;
            label142: 
            do
              while (true)
              {
                do
                {
                  while (true)
                  {
                    if (i != 0)
                      return localXHTMLExtension;
                    l = paramXmlPullParser.next();
                    if (l != 2)
                      break;
                    if (paramXmlPullParser.getName().equals("body"))
                    {
                      localStringBuilder = new StringBuilder();
                      k = paramXmlPullParser.getDepth();
                    }
                    str = paramXmlPullParser.getText();
                    localStringBuilder.append(paramXmlPullParser.getText());
                  }
                  if (l != 4)
                    break label142;
                }
                while (localStringBuilder == null);
                localStringBuilder.append(StringUtils.escapeForXML(paramXmlPullParser.getText()));
              }
            while (l != 3);
            if ((!(paramXmlPullParser.getName().equals("body"))) || (paramXmlPullParser.getDepth() > k))
              break;
            localStringBuilder.append(paramXmlPullParser.getText());
            localXHTMLExtension.addBody(localStringBuilder.toString());
          }
          if ((!(paramXmlPullParser.getName().equals(localXHTMLExtension.getElementName()))) || (paramXmlPullParser.getDepth() > j))
            break;
          i = 1;
        }
      while (str.equals(paramXmlPullParser.getText()));
      localStringBuilder.append(paramXmlPullParser.getText());
    }
  }
}